<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>View Delete Own Articles</title>
    </h:head>
    <h:body>
        <h:form id="articlesFormDelete" >
            <p:dataTable styleClass="sample" id="articleOwntable" value="#{ownArticlesBean.ownArticles}" var="ownArt"
                         paginator="true" rows="5"  
                         paginatorTemplate="{CurrentPageReport}  
                         {FirstPageLink} {PreviousPageLink} 
                         {PageLinks} {NextPageLink} 
                         {LastPageLink} {RowsPerPageDropdown}"  
                         rowsPerPageTemplate="5,10,15">
                <f:facet name="header">
                    <h:outputText value="My Articles" />
                </f:facet>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Id" />
                    </f:facet>
                    <h:outputText value="#{ownArt.id}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Status" />
                    </f:facet>
                    <h:outputText value="#{ownArt.status}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Date of publication" />
                    </f:facet>
                    <h:outputText value="#{ownArt.date}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Title" />
                    </f:facet>
                    <h:outputText value="#{ownArt.title}" />
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Article Text" />
                    </f:facet>
                    <h:outputText value="#{ownArt.articleBody}" />
                </p:column>
                <p:column id="columnOfActioninEditingArticle">
                    <f:facet name="header">
                        <h:outputText value="Select Action" />
                    </f:facet>
                    <h:panelGrid columns="2">
                        <p:column>
                            <p:commandButton  id="editOwnArticle" value="Edit" action="#{ownArticlesBean.retrieveSelectedArticle(ownArt.id)}" update="editArticleForm" oncomplete="dEditArticle.show()"></p:commandButton>
                        </p:column>
                        <p:column>
                            <p:commandButton id="delete" value="Delete" update="articlesFormDelete" actionListener="#{ownArticlesBean.deleteSelectedArticle(ownArt.id)}" />                
                        </p:column>
                    </h:panelGrid>
                </p:column>
            </p:dataTable>
            <br/>
            <p:commandButton  update="articlesFormDelete" actionListener="#{ownArticlesBean.retrieveOwnArticles()}" value="Show articles"/>
            <br/>
        </h:form>
    </h:body>
</html>

